package com.cloud.test02;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * request作用域
 * 作用范围：当前请求中
 *      通过该对象可以在一个请求中传递数据，作用范围：在一次请求中有效，即服务器跳转有效。（请求转发时有效）
 *      //设置域对象内容
 *      req.setAttribute(String,Object);
 *      //获取域对象内容
 *      req.getAttribute(name:String);
 *      //删除域对象内容
 *
 * @author DELL
 */

@WebServlet(value = {"/RTest06", "/rtest06"})
public class RequestTest06 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("----------Servlet06----------");
        //获取域对象内容
        String name = (String) req.getAttribute("name");
        String age = (String) req.getAttribute("age");
        List<String> list = (List<String>) req.getAttribute("list");

        System.out.println(name+" "+age +" " + list.get(0));
    }
}
